﻿Imports QueComer

Public Class GestionOfertas

    Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click

    End Sub

    Private Sub xnombre_MaskInputRejected(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MaskInputRejectedEventArgs) Handles xnombre.MaskInputRejected

    End Sub

    Private Sub btnBuscar99_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBuscar99.Click

        Dim nombrest = Me.Text
        Dim desc As String = Me.xnombre.Text
        Dim fi As String = Me.xespe.Text
        Dim ff As String = Me.xdistrito.Text

        Dim negocio As New Buscar
        Dim cat As Collection = negocio.buscaroferxdesc(nombrest, desc, fi, ff)
        Me.dgvplop.DataSource = cat
        Me.dgvplop.EditMode = False

        Me.dgvplop.Columns("Restaurante_idestaurant").Visible = False
        Me.dgvplop.Columns("idrestaurant").Visible = False
        Me.dgvplop.Columns("tipo_comida").Visible = False
        Me.dgvplop.Columns("distrito").Visible = False
        Me.dgvplop.Columns("direccion").Visible = False
        Me.dgvplop.Columns("ruc").Visible = False
        Me.dgvplop.Columns("nombre").Visible = False

    End Sub

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim tag = Me.Text
        Dim form As New NuevaOfer
        Dim negocio As New Gest_Ofer
        Dim wtf As New todo
        form.MdiParent = Me.MdiParent
        negocio.obtener2(tag)
        form.lblId.Text = wtf.idrestaurant
        form.GestionOfertas = Me
        form.Text = tag
        form.Show()
    End Sub

    Private Sub btnEliminar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEliminar.Click
        Try
            Dim seleccionado = Me.dgvplop.CurrentRow.Cells(0).Value.ToString
            Dim negocio As New Gestion_Rest
            negocio.eliminar(seleccionado)
            dgvplop.DataSource = ""
        Catch ex As Exception
            Me.lblError.Text = "No ha seleccionado ninguna oferta"
        End Try
    End Sub

    Private Sub btnEditar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEditar.Click
        Try
            Dim seleccionado = Me.dgvplop.CurrentRow.Cells(0).Value.ToString
            Dim form As New NuevaOfer
            form.MdiParent = Me.MdiParent
            form.lblId.Text = seleccionado
            form.GestionOfertas = Me
            form.Show()
        Catch ex As Exception
            Me.lblError.Text = "No ha seleccionado ningún restaurante"
        End Try
    End Sub
End Class